package com.mmy.dao.train;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mmy.domain.train.VTrainOrder;

public interface VTrainOrderRepository extends JpaRepository<VTrainOrder, Integer> {

	/*
	 * 根据ScenicID查找
	 */
	@Query(value = "select *  from vTrainOrder where left (cOrderID,6) = :iTrainID", nativeQuery = true)
	List<VTrainOrder> findByTrainID(@Param("iTrainID") int iTrainID);

	/*
	 * 根据出纳审核状态查找
	 */
	@Query(value = "select *  from vTrainOrder where iCashierState = :strCashierState and left (cOrderID,6) = :iTrainID", nativeQuery = true)
	List<VTrainOrder> findByCashierAndTrainID(@Param("strCashierState") String strCashierState,
			@Param("iTrainID") int iTrainID);

	/*
	 * 根据会计审核状态查找
	 */
	@Query(value = "select *  from vTrainOrder where iAccountState = :strAccountState and left (cOrderID,6) = :iTrainID", nativeQuery = true)
	List<VTrainOrder> findByAccountAndTrainID(@Param("strAccountState") String strAccountState,
			@Param("iTrainID") int iTrainID);

}
